<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>腹部专委会病例读片大赛</title>
</head>
<script src="js/jquery-2.1.1.min.js"></script>
<style type="text/css">
	body {
		background:url(img/ranking.jpg);
		text-align: center;
		font-size: 30px;
		font-family: 微软雅黑;
	}
	table td {
		margin: o auto;
		height: 74px;
	}
</style>

<body>
	<table style="width: 850px; height: 500px; margin-top: 250px; margin-left: 150px;" >
			<tr >
				<td style="width:370px; " id="h_1"></td>
				<td style="width:180px; " id="n_1"></td>
				<td style="width:150px; " id="d_1"></td>
				<td style="width:150px; " id="t_1"></td>
			</tr>
			<tr >
				<td style="width:370px; " id="h_2"></td>
				<td style="width:180px; " id="n_2"></td>
				<td style="width:150px; " id="d_2"></td>
				<td style="width:150px; " id="t_2"></td>
			</tr>
			<tr >
				<td style="width:370px; " id="h_3"></td>
				<td style="width:180px; " id="n_3"></td>
				<td style="width:150px; " id="d_3"></td>
				<td style="width:150px; " id="t_3"></td>
			</tr>
			<tr >
				<td style="width:370px; " id="h_4"></td>
				<td style="width:180px; " id="n_4"></td>
				<td style="width:150px; " id="d_4"></td>
				<td style="width:150px; " id="t_4"></td>
			</tr>
			<tr >
				<td style="width:370px; " id="h_5"></td>
				<td style="width:180px; " id="n_5"></td>
				<td style="width:150px; " id="d_5"></td>
				<td style="width:150px; " id="t_5"></td>
			</tr>
			<tr >
				<td style="width:370px; " id="h_6"></td>
				<td style="width:180px; " id="n_6"></td>
				<td style="width:150px; " id="d_6"></td>
				<td style="width:150px; " id="t_6"></td>
			</tr>
	</table>
</body>

<script type="text/javascript">
	$(function(){
    	getNewDataJson();	//开启获取最新消息
	});
	function getNewDataJson(){

		var url = "voteResult";
		$.ajax({
            url:url,
            type:'post',
            dataType:"Json",
            success:function(object){
            	console.info( object );
            	
                var results = object.voteResult ;
                for(var i = 0 ;i<results.length;i++){
					                	
                    console.info(" info =" + results[i].name );
                    
                    $("#error").text("姓名不能为空！");
      	         	$("#error").css({"color":"red"});  
                    
      	         	var index = i + 1 ;
      	         	
      	         	var h = "#h_" + index ;
      	         	var n = "#n_" + index ;
      	         	var d = "#d_" + index ;
      	         	var t = "#t_" + index ;
      	         	
      	         	console.info( "h =" + h + " , n =" + n + " , d =" + d + " , t =" + t );
	      	         	
                    var time = results[i].time ;
                    var hour =  parseInt( time / 1000 / 60 / 60 )  ;
                    var minute = parseInt ( time / 1000 / 60 ) ;
                    var second = parseInt ( time / 1000 );
                    
                    console.info(" time =" + time + " , hour =" + hour + " , minute =" + minute + " , second =" + second );
                    
                    var timeResult ;
                    
                    if ( hour >= 1 ) {
                    	timeResult = hour + ":" + hour + ":" + second ;
                    } else {
                    	if ( minute >= 1 ) {
                    		timeResult = minute + ":" + second ;
                    	} else {
                    		timeResult = "00:" + second ;
                    		console.info(" ----------- " + timeResult );
                    	}
                    }
                    
                    $( h ).text( results[i].hospital );
                    $( n ).text( results[i].name );
                    $( d ).text( results[i].fraction );
                    $( t ).text( timeResult );
                    
                }
                
            },
            error:function(){ 
                console.log("ajax error");
            }
        });
				
	}
</script>

</html>